﻿using Cms.Core.Application.IService;
using Cms.Core.DynamicWebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;

namespace Cms.Core.Application.Service
{
    /// <summary>
    /// 测试动态路由
    /// </summary>
    [AllowAnonymous]
    [Route("api/[controller]/[action]")]
    public class TestAppService : ITestAppService
    {

        private static readonly Dictionary<int, string> Tests = new Dictionary<int, string>()
        {
            [1] = "Big Test",
            [2] = "Small Test"
        };

        /// <summary>
        /// Get An Test.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id:int}")]
        public string Get(int id)
        {
            if (Tests.ContainsKey(id))
            {
                return Tests[id];
            }
            else
            {
                return "No Test!";
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IEnumerable<string> GetAllAsync()
        {
            return Tests.Values;
        }

        /// <summary>
        /// 得到
        /// </summary>
        /// <returns></returns>
        public IEnumerable<string> Get()
        {
            return Tests.Values;
        }

        /// <summary>
        /// dfsd
        /// </summary>
        /// <returns></returns>
     
        public IEnumerable<string> GetBigTest()
        {
            return Tests.Values;
        }

        /// <summary>
        /// 更新
        /// </summary>
        public void Update()
        {
 
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
    
        [HttpDelete("{id:int}")]
        public void Delete(int id)
        {
            if (Tests.ContainsKey(id))
            {
                Tests.Remove(id);
            }
        }

        [HttpPost]
        public string DDa()
        {
            return "No DDa!";
        }
    }
}
